﻿/*
 *   CalculatorContext.cs
 *   Copyright (c) 2011 - BitFox Software and Ricardo Federico Villafañes
 *   Contact: federvillaf@hotmail.com
 *   
 *   Licensing: This product is covered by Microsoft Reciprocal License (MS-RL)
 *              see https://bitfoxeval.codeplex.com/license
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics.CodeAnalysis;

namespace BitFox.Evaluator
{
    /// <summary>
    /// This class stores a group of settings that could alter the function of some evaluator's feature.
    /// </summary>
    public class CalculatorContext
    {
        /// <summary>
        /// The alu used to do some operations.
        /// </summary>
        Alu alu;

        /// <summary>
        /// The ALU used in conjunction with this context
        /// </summary>
        internal Alu Alu
        {
            get
            {
                if (alu == null) alu = new Alu(this);
                return alu;
            }
        }

        /// <summary>
        /// The way in which a given string can be parsed to a date/datetime, or the way in which a 
        /// datetime is converted to string.
        /// </summary>
        public SetDateOptions SetDate { get; set; }

        /// <summary>
        /// A setting that indicates if the century must be shown when a date/datetime is converted to string.
        /// </summary>
        public bool SetCenturyOn { get; set; }

        /// <summary>
        /// A setting that indicates if indices of an array starts in zero or one (default, ONE).
        /// </summary>
        public bool ArrayIndexBaseZero { get; set; }

        /// <summary>
        /// A setting that indicates the number of decimal positions to use as default for certaing operations (like ROUND)
        /// </summary>
        public int SetDecimals { get; set; }

        /// <summary>
        /// Constructor
        /// </summary>
        public CalculatorContext()
        {
            SetDate = SetDateOptions.American;
            SetCenturyOn = false;
            ArrayIndexBaseZero = false;
            SetDecimals = 2;
        }
    }

    /// <summary>
    /// The possible formats for convertion of dates between strings and Date types.
    /// </summary>
    public enum SetDateOptions
    {
        /// <summary>
        /// MONTH/DAY/YEAR
        /// </summary>
        American,

        /// <summary>
        /// Format: YEAR.MONTH.DAY
        /// </summary>
        Ansi,
 
        /// <summary>
        /// Format: DAY/MONTH/YEAR
        /// </summary>
        British,

        /// <summary>
        /// Format: DAY/MONTH/YEAR
        /// </summary>
        French, 
        
        /// <summary>
        /// Format: DAY.MONTH.YEAR
        /// </summary>
        German, 
        
        /// <summary>
        /// Format: DAY-MONT-YEAR
        /// </summary>
        Italian, 
        
        /// <summary>
        /// Format: YEAR/MONTH/DATY
        /// </summary>
        Japan,

        /// <summary>
        /// MONTH-DAY-YEAR
        /// </summary>
        Usa,

        /// <summary>
        /// MONTH/DAY/YEAR
        /// </summary>
        [SuppressMessage("Microsoft.Naming", "CA1709")]
        MDY,

        /// <summary>
        /// Format: DAY/MONTH/YEAR
        /// </summary>
        [SuppressMessage("Microsoft.Naming", "CA1709")]
        DMY,

        /// <summary>
        /// Format: YEAR/MONTH/DATY
        /// </summary>
        [SuppressMessage("Microsoft.Naming", "CA1709")]
        YMD
    }
}
